package com.example.kotlin.basis

/**
 * Created by xiao_tan on 17/7/23.
 * when
 */

fun main(args:Array<String>){

    gradeStudent(10)
    gradeStudent(9)
    gradeStudent(8)
    gradeStudent(7)
    gradeStudent(6)
    gradeStudent(3)

    var num = 5
    var num2 = 7
    println("${num}:" + numToChinese(num))
    println("${num2}:" + numToChinese(num2))
}

fun gradeStudent(score:Int){
    when(score){
        10 -> println("考了满分!")
        9 -> println("干的不错!")
        8 -> println("还可以!")
        7 -> println("还需努力!")
        6 -> println("刚好及格!")
        else -> println("你需要加油了!")
    }
}

fun numToChinese(num:Int):String{
    var result = when(num){
        1 -> "一"
        2 -> "二"
        3 -> "三"
        4 -> "四"
        5 -> "五"
        else -> num.toString()
    }
    return result;
}
